package com.sou.technologytool.ui;


import android.content.Intent;
import android.os.Handler;

import com.benben.commoncore.utils.StatusBarUtils;
import com.sou.technologytool.MyApplication;
import com.sou.technologytool.R;
import com.sou.technologytool.base.BaseActivity;
import com.sou.technologytool.ui.login.LoginActivity;

public class SplashActivity extends BaseActivity {

    @Override
    protected int getLayoutId() {
        return R.layout.activity_splash;
    }

    @Override
    protected void initData() {
        StatusBarUtils.fullScreen(this,R.color.black);
        StatusBarUtils.setAndroidNativeLightStatusBar(mContext, needStatusBarDarkText());
        requestPermissionAndShotView();
    }

    private void requestPermissionAndShotView() {
        new Handler().postDelayed(new Runnable() {
            @Override
            public void run() {
                toMainPager();
            }
        }, 1500);
    }

    private void toMainPager() {
        if (MyApplication.mPreferenceProvider.getIsLogin()) {
            Intent intent = new Intent(mContext, MainActivity.class);
            startActivity(intent);
            finish();
        } else {
            Intent intent = new Intent(mContext, LoginActivity.class);
            startActivity(intent);
            finish();
        }
    }
}
